﻿Public Class TaoSuaThuChiCoDinh
    Public RowUpdate As DataRow 'thong tin ve item duoc update
    Public index As Integer 'chi so cua item dang duoc chon de cap nhat
    Public Sub SetTitle(ByVal title As String)
        ThuChiCoDinhUC1.Label_header.Text = title
    End Sub
    Public Sub Settab(ByVal tentab As String)
        ThuChiCoDinhUC1.tab = tentab
    End Sub

    Public Sub SuaDoiTuong()
        ThuChiCoDinhUC1.Flag = 1
        ThuChiCoDinhUC1.id = RowUpdate(0)
        ThuChiCoDinhUC1.tb_sotien.Text = RowUpdate(1)
        ThuChiCoDinhUC1.cb_loai_tk.SelectedValue = RowUpdate(2)
        ThuChiCoDinhUC1.cb_danhmuc_thu.SelectedValue = RowUpdate(4)
        ThuChiCoDinhUC1.tb_chitiet.Text = RowUpdate(6)
        ThuChiCoDinhUC1.nud_ngaythu.Value = RowUpdate(7)
        ThuChiCoDinhUC1.cb_nguoi_thu.SelectedValue = RowUpdate(10)
        ThuChiCoDinhUC1.tb_dathu.Text = RowUpdate(12)
    End Sub

    Private Sub ThuChiCoDinhUC1_ButtonDongClick_1() Handles ThuChiCoDinhUC1.ButtonDongClick
        Me.Dispose()
    End Sub

    Private Sub ThuChiCoDinhUC1_ButtonLuuClick(dongmoi As System.Data.DataRow, kieu As System.Int32) Handles ThuChiCoDinhUC1.ButtonLuuClick
        If kieu = 0 Then
            If ThuChiCoDinhUC1.tab = "thu" Then
                ThuChiCoDinh.DSThu.Rows.Add(dongmoi)
            Else
                ThuChiCoDinh.DSChi.Rows.Add(dongmoi)
            End If
        ElseIf kieu = 1 Then
            If ThuChiCoDinhUC1.tab = "thu" Then
                ThuChiCoDinh.DSThu.Rows(index).Item(0) = dongmoi(0)
                ThuChiCoDinh.DSThu.Rows(index).Item(1) = dongmoi(1)
                ThuChiCoDinh.DSThu.Rows(index).Item(2) = dongmoi(2)
                ThuChiCoDinh.DSThu.Rows(index).Item(3) = dongmoi(3)
                ThuChiCoDinh.DSThu.Rows(index).Item(4) = dongmoi(4)
                ThuChiCoDinh.DSThu.Rows(index).Item(5) = dongmoi(5)
                ThuChiCoDinh.DSThu.Rows(index).Item(6) = dongmoi(6)
                ThuChiCoDinh.DSThu.Rows(index).Item(7) = dongmoi(7)
                ThuChiCoDinh.DSThu.Rows(index).Item(8) = dongmoi(8)
                ThuChiCoDinh.DSThu.Rows(index).Item(9) = dongmoi(9)
                ThuChiCoDinh.DSThu.Rows(index).Item(10) = dongmoi(10)
                ThuChiCoDinh.DSThu.Rows(index).Item(11) = dongmoi(11)
                ThuChiCoDinh.DSThu.Rows(index).Item(12) = dongmoi(12)
            Else
                ThuChiCoDinh.DSChi.Rows(index).Item(0) = dongmoi(0)
                ThuChiCoDinh.DSChi.Rows(index).Item(1) = dongmoi(1)
                ThuChiCoDinh.DSChi.Rows(index).Item(2) = dongmoi(2)
                ThuChiCoDinh.DSChi.Rows(index).Item(3) = dongmoi(3)
                ThuChiCoDinh.DSChi.Rows(index).Item(4) = dongmoi(4)
                ThuChiCoDinh.DSChi.Rows(index).Item(5) = dongmoi(5)
                ThuChiCoDinh.DSChi.Rows(index).Item(6) = dongmoi(6)
                ThuChiCoDinh.DSChi.Rows(index).Item(7) = dongmoi(7)
                ThuChiCoDinh.DSChi.Rows(index).Item(8) = dongmoi(8)
                ThuChiCoDinh.DSChi.Rows(index).Item(9) = dongmoi(9)
                ThuChiCoDinh.DSChi.Rows(index).Item(10) = dongmoi(10)
                ThuChiCoDinh.DSChi.Rows(index).Item(11) = dongmoi(11)
                ThuChiCoDinh.DSChi.Rows(index).Item(12) = dongmoi(12)
            End If
        End If
    End Sub
End Class